<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="Ccab.jsp" %>
<%@ page import="modelo.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<link href="../css/style.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="../js/view.css" media="all">
<script language="javascript" src="../js/funciones.js"> </script>
<script type="text/javascript" src="../js/view.js"></script>

<title>Registrar Articulo</title>
</head>
<body>

<%
    String tipoUsua = (String) request.getSession().getAttribute("tipo");
	if(tipoUsua != null){
		
		if(tipoUsua.equalsIgnoreCase("administrador")){
		Articulo articulo = (Articulo) request.getSession().getAttribute("articuloM");
		String accion;
		if (articulo==null) accion="../ControladorFrontal?command=CommandGuardarArticulo";
		else accion="../ControladorFrontal?command=CommandModificarArticulo&comando=nomostrar";
%>



<form action="<%out.print(accion);%>" method="post" onsubmit= "return validarDatosFormularioArticulo();" name="frmArticulo" id="frmArticulo" enctype="multipart/form-data">
<table width="100%" cellspacing="0" border="0" cellpadding="0">
	<tr>
	  <td id='celda'>
	   <div align="center">
	   <br><br>
		<h1>Datos del Articulo:</h1>
		 	<br>	 		
			<table cellspacing="0"  cellpadding="0">
			<tr>
				<input type="hidden" name="id" value="<%if (articulo!=null) out.print(articulo.getId());%>"></input>
				<td width="80px" height="40px">Codigo:</td>
				<td><input type="text" name="codigo" value="<%if (articulo!=null) out.print(articulo.getCodigo());%>" size="10"  maxlength="8" onkeypress="return validarEntero(event)"   ></input></td>
			</tr>
			<tr>
				<td width="80px" height="40px">Nombre</td>
				<td><input type="text" name="nombre" value="<%if (articulo!=null) out.print(articulo.getNombre());%>" size="20" maxlength="50"  onkeypress="return validarSoloLetras(event)"></input></td>
			</tr>
			
			
			<tr>
			<td width="80px" height="40px">Categorí­a</td>
			<td>
				<select	name="categoria">
					<option value="Ropa">Ropa</option>
					<option value="Zapatos">Zapatos</option>
					<option value="Carteras">Carteras</option>			
					<option value="Perfumes">Perfumes</option>
					<option value="Accesorios">Accesorios</option>
				</select> 	
			</td>
		</tr>
			<tr>
				<td width="80px" height="40px">Costo:</td>
				<td><input type="text" name="costo" value="<%if (articulo!=null) out.print(articulo.getCosto());%>" size="20" maxlength="50"  onkeypress="return validarFloat(event)"></input></td>
			</tr>
			<tr>
				<td width="80px" height="40px">Precio:</td>			
				<td><input type="text" name="precio" value="<%if (articulo!=null) out.print(articulo.getPrecio());%>" size="10" maxlength="50"  onkeypress="return validarFloat(event)"></input></td>
			</tr>
			<tr>
				<td width="80px" height="40px">Existencia:</td>			
				<td><input type="text" name="existencia" value="<%if (articulo!=null) out.print(articulo.getExistencia());%>" size="10" maxlength="50"  onkeypress="return validarEntero(event)"></input></td>
			</tr>
			
	
				
				<tr>
					<td class="etiqueta"><label>Imagen</label></td>
					<td><input type="file" id = "imagen" class="campo" style="width:400px;" accept="image/*" 
					 name="imagen" size="30"  value=""></input></td>
				</tr>
			
			<% 
			
			if (articulo!=null){
			%>
			 <td><img width="100%"  border="0" src="/ComercioGT/<%=articulo.getImagen()%>" /></td>
			<% 
			}
			   
			
			%>
				<tr>
				<td colspan="2" align="center">		
				    &nbsp;		
				 </td>
			</tr>
			<tr>
				<td colspan="2" align="center">		
					<input type="submit" name="botonEnviar" value="Enviar"></input>		
					<input type="reset" name="botonLimpiar" value="Limpiar"></input>	
				 </td>
			</tr>
				
		</table>
	   </div>
	   <br><br><br>
	 </td>
	</tr>
</table>
</form>
<div id="copyright">
				&copy;  Proyecto | Design: <a href="www.guillemox_asarox.wix.com/marca-personal">Asaro Guillermo and <a href="www.suarezcumare.wix.com/tonysuarez"> Suarez Tony</a> </a>
			</div>

<% 
	} else {
		response.sendRedirect("../index.jsp");
	} 
	} else {
		response.sendRedirect("../index.jsp");
	}
%>
</body>
</html>
